##cmake_minimum_required( VERSION 2.8 )
project("ts plugin database mysql")
find_package( Qt4 REQUIRED )

ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_PLUGIN)
#ADD_DEFINITIONS(-DQT_NO_DEBUG)
ADD_DEFINITIONS(-DQT_SHARED)

include( ${QT_USE_FILE} )
INCLUDE_DIRECTORIES(
    ${QT_INCLUDE_DIR}
    ${QT_QTSQL_INCLUDE_DIR}
    ${CMAKE_CURRENT_BINARY_DIR}
    ../../../core/interfaces
)


set(INSTPREF ${CMAKE_INSTALL_PREFIX})
configure_file(../../../core/src/def.h.in def.h)
set( HEADERS
        tspldb_mysql.h
        dbthread.h
	)
set( SOURCES 
        tspldb_mysql.cpp
        dbthread.cpp
	)

qt4_wrap_cpp(MOC ${HEADERS})

add_library(db_mysql SHARED ${SOURCES} ${MOC})

target_link_libraries(db_mysql ${QT_LIBRARIES} ${QT_QTSQL_LIBRARIES})

# install for linux
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
	set(tsdir ${CMAKE_INSTALL_PREFIX})
        set(tsdir_pl ${tsdir}/lib/torisakura)
        install(TARGETS db_mysql DESTINATION ${tsdir_pl})
endif()
